﻿var win ;

function NewWindow(windowUrl,windowName,windowWidth,windowHeight,isScroll)
{
    var windowSetting = "width="+windowWidth+",height="+windowHeight+",scrollbars="+isScroll+",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no" ;
    //alert(win);
    if ( win == null )
    {
        window.open(windowUrl,windowName,windowSetting);
    }
    else 
    {
        try
        {
            win.focus() ;
        }
        catch(ex)
        {
            window.open(windowUrl,windowName,windowSetting);
        }
    }
}

function NewWindowInCenter(windowUrl,windowName,windowWidth,windowHeight,isScroll)
{
    var windowLeft = document.documentElement.clientWidth/2-windowWidth/2 ;
    var windowTop = document.documentElement.clientHeight/2-windowHeight/2 ;
    var windowSetting = "left="+windowLeft+",top="+windowTop+",width="+windowWidth+",height="+windowHeight+",scrollbars="+isScroll+",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no" ;

    if ( win == null )
    {
        win = window.open(windowUrl,windowName,windowSetting);
    }
    else 
    {
        try
        {
            win.focus() ;
        }
        catch(ex)
        {
            win = window.open(windowUrl,windowName,windowSetting);
        }
    }
}

function NewWindowInCenterChatOrMessage(windowUrl,windowName,windowWidth,windowHeight,isScroll,isOpen)
{
    var windowLeft = document.documentElement.clientWidth/2-windowWidth/2 ;
    var windowTop = document.documentElement.clientHeight/2-windowHeight/2 ;
    var windowSetting = "left="+windowLeft+",top="+windowTop+",width="+windowWidth+",height="+windowHeight+",scrollbars="+isScroll+",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no" ;

	try
	{
		if(win!=null && win.isOpen==1)
		{
			win.focus();
		}
		else
		{
			win=window.open(windowUrl,"_self",windowSetting);
		}
	}
	catch(err)
	{
	    try
	    {
		    win=window.open(windowUrl,"_self",windowSetting);
	    }
	    catch(ss)
	    {
	    }
	}
}

if(typeof(ODD_regetnewCookie) != 'function')
{
    function ODD_regetnewCookie(VisitorGuid)
    {
	    var cval=null;
	    var name='EzhenDDVisitorGuid';
	    var arr = document.cookie.match(new RegExp('(^| )'+name+'=([^;]*)(;|$)'));
	    if(arr != null) 
		    cval=unescape(arr[2]);
	    if(cval==null)
	    {
		    var path=';path=/;';
		    var expire = new Date((new Date()).getTime() + 315360000000).toGMTString();
		    expire = '; expires=' + expire;
		    var value= VisitorGuid;
		    document.cookie = name + '=' + escape(value) + expire+path;
		    arr = document.cookie.match(new RegExp('(^| )'+name+'=([^;]*)(;|$)'));
		    if(arr != null) 
			    cval=unescape(arr[2]);
	    }
	    if(cval != null)
	    {
		    return cval;
	    }
	    return value;
    }
};  
